home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / tests / entry.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  37.6 KB  |  1,248 lines  |  [TEXT/ALFA]

  1. # This file is a Tcl script to test entry widgets in Tk.  It is
  2. # organized in the standard fashion for Tcl tests.
  3. #
  4. # Copyright (c) 1994 The Regents of the University of California.
  5. # Copyright (c) 1994-1997 Sun Microsystems, Inc.
  6. #
  7. # See the file "license.terms" for information on usage and redistribution
  8. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9. #
  10. # SCCS: @(#) entry.test 1.46 97/07/31 09:56:00
  11.  
  12. if {[lsearch [image types] test] < 0} {
  13.     puts "This application hasn't been compiled with the \"test\""
  14.     puts "image, so I can't run this test.  Are you sure you're using"
  15.     puts "tktest instead of wish?"
  16.     return
  17. }
  18.  
  19. if {[info procs test] != "test"} {
  20.     source defs
  21. }
  22.  
  23. foreach i [winfo children .] {
  24.     destroy $i
  25. }
  26. wm geometry . {}
  27. raise .
  28.  
  29. proc scroll args {
  30.     global scrollInfo
  31.     set scrollInfo $args
  32. }
  33.  
  34. # Create additional widget that's used to hold the selection at times.
  35.  
  36. entry .sel
  37. .sel insert end "This is some sample text"
  38.  
  39. # Font names
  40.  
  41. set big -adobe-helvetica-medium-r-normal--24-240-75-75-p-*-iso8859-1
  42. set fixed -adobe-courier-medium-r-normal--12-120-75-75-m-*-iso8859-1
  43.  
  44. # Create entries in the option database to be sure that geometry options
  45. # like border width have predictable values.
  46.  
  47. option add *Entry.borderWidth 2
  48. option add *Entry.highlightThickness 2
  49. option add *Entry.font {Helvetica -12}
  50.  
  51. entry .e -bd 2 -relief sunken
  52. pack .e
  53. update
  54. set i 1
  55. foreach test {
  56.     {-background #ff0000 #ff0000 non-existent
  57.         {unknown color name "non-existent"}}
  58.     {-bd 4 4 badValue {bad screen distance "badValue"}}
  59.     {-bg #ff0000 #ff0000 non-existent {unknown color name "non-existent"}}
  60.     {-borderwidth 1.3 1 badValue {bad screen distance "badValue"}}
  61.     {-cursor arrow arrow badValue {bad cursor spec "badValue"}}
  62.     {-exportselection yes 1 xyzzy {expected boolean value but got "xyzzy"}}
  63.     {-fg #110022 #110022 bogus {unknown color name "bogus"}}
  64.     {-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*
  65.     -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* {}
  66.     {font "" doesn't exist}}
  67.     {-foreground #110022 #110022 bogus {unknown color name "bogus"}}
  68.     {-highlightbackground #123456 #123456 ugly {unknown color name "ugly"}}
  69.     {-highlightcolor #123456 #123456 bogus {unknown color name "bogus"}}
  70.     {-highlightthickness 6 6 bogus {bad screen distance "bogus"}}
  71.     {-highlightthickness -2 0 {} {}}
  72.     {-insertbackground #110022 #110022 bogus {unknown color name "bogus"}}
  73.     {-insertborderwidth 1.3 1 2.6x {bad screen distance "2.6x"}}
  74.     {-insertofftime 100 100 3.2 {expected integer but got "3.2"}}
  75.     {-insertontime 100 100 3.2 {expected integer but got "3.2"}}
  76.     {-justify right right bogus {bad justification "bogus": must be left, right, or center}}
  77.     {-relief groove groove 1.5 {bad relief type "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
  78.     {-selectbackground #110022 #110022 bogus {unknown color name "bogus"}}
  79.     {-selectborderwidth 1.3 1 badValue {bad screen distance "badValue"}}
  80.     {-selectforeground #654321 #654321 bogus {unknown color name "bogus"}}
  81.     {-show * * {} {}}
  82.     {-state normal normal bogus {bad state value "bogus": must be normal or disabled}}
  83.     {-takefocus "any string" "any string" {} {}}
  84.     {-textvariable i i {} {}}
  85.     {-width 402 402 3p {expected integer but got "3p"}}
  86.     {-xscrollcommand {Some command} {Some command} {} {}}
  87. } {
  88.     set name [lindex $test 0]
  89.     test entry-1.$i {configuration options} {
  90.     .e configure $name [lindex $test 1]
  91.     list [lindex [.e configure $name] 4] [.e cget $name]
  92.     } [list [lindex $test 2] [lindex $test 2]]
  93.     incr i
  94.     if {[lindex $test 3] != ""} {
  95.     test entry-1.$i {configuration options} {
  96.         list [catch {.e configure $name [lindex $test 3]} msg] $msg
  97.     } [list 1 [lindex $test 4]]
  98.     }
  99.     .e configure $name [lindex [.e configure $name] 3]
  100.     incr i
  101. }
  102.  
  103. test entry-2.1 {Tk_EntryCmd procedure} {
  104.     list [catch {entry} msg] $msg
  105. } {1 {wrong # args: should be "entry pathName ?options?"}}
  106. test entry-2.2 {Tk_EntryCmd procedure} {
  107.     list [catch {entry gorp} msg] $msg
  108. } {1 {bad window path name "gorp"}}
  109. test entry-2.3 {Tk_EntryCmd procedure} {
  110.     catch {destroy .e}
  111.     entry .e
  112.     list [winfo exists .e] [winfo class .e] [info commands .e]
  113. } {1 Entry .e}
  114. test entry-2.4 {Tk_EntryCmd procedure} {
  115.     catch {destroy .e}
  116.     list [catch {entry .e -gorp foo} msg] $msg [winfo exists .e] \
  117.         [info commands .e]
  118. } {1 {unknown option "-gorp"} 0 {}}
  119. test entry-2.5 {Tk_EntryCmd procedure} {
  120.     catch {destroy .e}
  121.     entry .e
  122. } {.e}
  123.  
  124. catch {destroy .e}
  125. entry .e -font $fixed
  126. pack .e
  127. update
  128.  
  129. set cx [font measure $fixed a]
  130. set cy [font metrics $fixed -linespace]
  131.  
  132. test entry-3.1 {EntryWidgetCmd procedure} {
  133.     list [catch {.e} msg] $msg
  134. } {1 {wrong # args: should be ".e option ?arg arg ...?"}}
  135. test entry-3.2 {EntryWidgetCmd procedure, "bbox" widget command} {
  136.     list [catch {.e bbox} msg] $msg
  137. } {1 {wrong # args: should be ".e bbox index"}}
  138. test entry-3.3 {EntryWidgetCmd procedure, "bbox" widget command} {
  139.     list [catch {.e bbox a b} msg] $msg
  140. } {1 {wrong # args: should be ".e bbox index"}}
  141. test entry-3.4 {EntryWidgetCmd procedure, "bbox" widget command} {
  142.     list [catch {.e bbox bogus} msg] $msg
  143. } {1 {bad entry index "bogus"}}
  144. test entry-3.5 {EntryWidgetCmd procedure, "bbox" widget command} {
  145.     .e delete 0 end
  146.     .e bbox 0
  147. } [list 5 5 0 $cy]
  148. test entry-3.6 {EntryWidgetCmd procedure, "bbox" widget command} {fonts} {
  149.     .e delete 0 end
  150.     .e insert 0 "abcdefghijklmnop"
  151.     list [.e bbox 0] [.e bbox 1] [.e bbox end]
  152. } [list "5 5 $cx $cy" "[expr 5+$cx] 5 $cx $cy" "[expr 5+15*$cx] 5 $cx $cy"]
  153. test entry-3.7 {EntryWidgetCmd procedure, "cget" widget command} {
  154.     list [catch {.e cget} msg] $msg
  155. } {1 {wrong # args: should be ".e cget option"}}
  156. test entry-3.8 {EntryWidgetCmd procedure, "cget" widget command} {
  157.     list [catch {.e cget a b} msg] $msg
  158. } {1 {wrong # args: should be ".e cget option"}}
  159. test entry-3.9 {EntryWidgetCmd procedure, "cget" widget command} {
  160.     list [catch {.e cget -gorp} msg] $msg
  161. } {1 {unknown option "-gorp"}}
  162. test entry-3.10 {EntryWidgetCmd procedure, "cget" widget command} {
  163.     .e configure -bd 4
  164.     .e cget -bd
  165. } {4}
  166. test entry-3.11 {EntryWidgetCmd procedure, "configure" widget command} {
  167.     llength [.e configure]
  168. } {28}
  169. test entry-3.12 {EntryWidgetCmd procedure, "configure" widget command} {
  170.     list [catch {.e configure -foo} msg] $msg
  171. } {1 {unknown option "-foo"}}
  172. test entry-3.13 {EntryWidgetCmd procedure, "configure" widget command} {
  173.     .e configure -bd 4
  174.     .e configure -bg #ffffff
  175.     lindex [.e configure -bd] 4
  176. } {4}
  177. test entry-3.14 {EntryWidgetCmd procedure, "delete" widget command} {
  178.     list [catch {.e delete} msg] $msg
  179. } {1 {wrong # args: should be ".e delete firstIndex ?lastIndex?"}}
  180. test entry-3.15 {EntryWidgetCmd procedure, "delete" widget command} {
  181.     list [catch {.e delete a b c} msg] $msg
  182. } {1 {wrong # args: should be ".e delete firstIndex ?lastIndex?"}}
  183. test entry-3.16 {EntryWidgetCmd procedure, "delete" widget command} {
  184.     list [catch {.e delete foo} msg] $msg
  185. } {1 {bad entry index "foo"}}
  186. test entry-3.17 {EntryWidgetCmd procedure, "delete" widget command} {
  187.     list [catch {.e delete 0 bar} msg] $msg
  188. } {1 {bad entry index "bar"}}
  189. test entry-3.18 {EntryWidgetCmd procedure, "delete" widget command} {
  190.     .e delete 0 end
  191.     .e insert end "01234567890"
  192.     .e delete 2 4
  193.     .e get
  194. } {014567890}
  195. test entry-3.19 {EntryWidgetCmd procedure, "delete" widget command} {
  196.     .e delete 0 end
  197.     .e insert end "01234567890"
  198.     .e delete 6
  199.     .e get
  200. } {0123457890}
  201. test entry-3.20 {EntryWidgetCmd procedure, "delete" widget command} {
  202.     .e delete 0 end
  203.     .e insert end "01234567890"
  204.     .e delete 6 5
  205.     .e get
  206. } {01234567890}
  207. test entry-3.21 {EntryWidgetCmd procedure, "delete" widget command} {
  208.     .e delete 0 end
  209.     .e insert end "01234567890"
  210.     .e configure -state disabled
  211.     .e delete 2 8
  212.     .e configure -state normal
  213.     .e get
  214. } {01234567890}
  215. test entry-3.22 {EntryWidgetCmd procedure, "get" widget command} {
  216.     list [catch {.e get foo} msg] $msg
  217. } {1 {wrong # args: should be ".e get"}}
  218. test entry-3.23 {EntryWidgetCmd procedure, "icursor" widget command} {
  219.     list [catch {.e icursor} msg] $msg
  220. } {1 {wrong # args: should be ".e icursor pos"}}
  221. test entry-3.24 {EntryWidgetCmd procedure, "icursor" widget command} {
  222.     list [catch {.e icursor foo} msg] $msg
  223. } {1 {bad entry index "foo"}}
  224. test entry-3.25 {EntryWidgetCmd procedure, "icursor" widget command} {
  225.     .e delete 0 end
  226.     .e insert end "01234567890"
  227.     .e icursor 4
  228.     .e index insert
  229. } {4}
  230. test entry-3.26 {EntryWidgetCmd procedure, "index" widget command} {
  231.     list [catch {.e in} msg] $msg
  232. } {1 {bad option "in": must be bbox, cget, configure, delete, get, icursor, index, insert, scan, selection, or xview}}
  233. test entry-3.27 {EntryWidgetCmd procedure, "index" widget command} {
  234.     list [catch {.e index} msg] $msg
  235. } {1 {wrong # args: should be ".e index string"}}
  236. test entry-3.28 {EntryWidgetCmd procedure, "index" widget command} {
  237.     list [catch {.e index foo} msg] $msg
  238. } {1 {bad entry index "foo"}}
  239. test entry-3.29 {EntryWidgetCmd procedure, "index" widget command} {
  240.     list [catch {.e index 0} msg] $msg
  241. } {0 0}
  242. test entry-3.30 {EntryWidgetCmd procedure, "insert" widget command} {
  243.     list [catch {.e insert a} msg] $msg
  244. } {1 {wrong # args: should be ".e insert index text"}}
  245. test entry-3.31 {EntryWidgetCmd procedure, "insert" widget command} {
  246.     list [catch {.e insert a b c} msg] $msg
  247. } {1 {wrong # args: should be ".e insert index text"}}
  248. test entry-3.32 {EntryWidgetCmd procedure, "insert" widget command} {
  249.     list [catch {.e insert foo Text} msg] $msg
  250. } {1 {bad entry index "foo"}}
  251. test entry-3.33 {EntryWidgetCmd procedure, "insert" widget command} {
  252.     .e delete 0 end
  253.     .e insert end "01234567890"
  254.     .e insert 3 xxx
  255.     .e get
  256. } {012xxx34567890}
  257. test entry-3.34 {EntryWidgetCmd procedure, "insert" widget command} {
  258.     .e delete 0 end
  259.     .e insert end "01234567890"
  260.     .e configure -state disabled
  261.     .e insert 3 xxx
  262.     .e configure -state normal
  263.     .e get
  264. } {01234567890}
  265. test entry-3.35 {EntryWidgetCmd procedure, "insert" widget command} {
  266.     list [catch {.e insert a b c} msg] $msg
  267. } {1 {wrong # args: should be ".e insert index text"}}
  268. test entry-3.36 {EntryWidgetCmd procedure, "scan" widget command} {
  269.     list [catch {.e scan a} msg] $msg
  270. } {1 {wrong # args: should be ".e scan mark|dragto x"}}
  271. test entry-3.37 {EntryWidgetCmd procedure, "scan" widget command} {
  272.     list [catch {.e scan a b c} msg] $msg
  273. } {1 {wrong # args: should be ".e scan mark|dragto x"}}
  274. test entry-3.38 {EntryWidgetCmd procedure, "scan" widget command} {
  275.     list [catch {.e scan foobar 20} msg] $msg
  276. } {1 {bad scan option "foobar": must be mark or dragto}}
  277. test entry-3.39 {EntryWidgetCmd procedure, "scan" widget command} {
  278.     list [catch {.e scan mark 20.1} msg] $msg
  279. } {1 {expected integer but got "20.1"}}
  280. # This test is non-portable because character sizes vary.
  281.  
  282. test entry-3.40 {EntryWidgetCmd procedure, "scan" widget command} {fonts} {
  283.     .e delete 0 end
  284.     update
  285.     .e insert end "This is quite a long string, in fact a "
  286.     .e insert end "very very long string"
  287.     .e scan mark 30
  288.     .e scan dragto 28
  289.     .e index @0
  290. } {2}
  291. test entry-3.41 {EntryWidgetCmd procedure, "select" widget command} {
  292.     list [catch {.e select} msg] $msg
  293. } {1 {wrong # args: should be ".e select option ?index?"}}
  294. test entry-3.42 {EntryWidgetCmd procedure, "select" widget command} {
  295.     list [catch {.e select foo} msg] $msg
  296. } {1 {bad selection option "foo": must be adjust, clear, from, present, range, or to}}
  297. test entry-3.43 {EntryWidgetCmd procedure, "select clear" widget command} {
  298.     list [catch {.e select clear gorp} msg] $msg
  299. } {1 {wrong # args: should be ".e selection clear"}}
  300. test entry-3.44 {EntryWidgetCmd procedure, "select clear" widget command} {
  301.     .e delete 0 end
  302.     .e insert end "0123456789"
  303.     .e select from 1
  304.     .e select to 4
  305.     update
  306.     .e select clear
  307.     list [catch {selection get} msg] $msg [selection own]
  308. } {1 {PRIMARY selection doesn't exist or form "STRING" not defined} .e}
  309. test entry-3.45 {EntryWidgetCmd procedure, "selection present" widget command} {
  310.     list [catch {.e selection present foo} msg] $msg
  311. } {1 {wrong # args: should be ".e selection present"}}
  312. test entry-3.46 {EntryWidgetCmd procedure, "selection present" widget command} {
  313.     .e delete 0 end
  314.     .e insert end 0123456789
  315.     .e select from 3
  316.     .e select to 6
  317.     .e selection present
  318. } {1}
  319. test entry-3.47 {EntryWidgetCmd procedure, "selection present" widget command} {
  320.     .e delete 0 end
  321.     .e insert end 0123456789
  322.     .e select from 3
  323.     .e select to 6
  324.     .e configure -exportselection false
  325.     .e selection present
  326. } {1}
  327. .e configure -exportselection true
  328. test entry-3.48 {EntryWidgetCmd procedure, "selection present" widget command} {
  329.     .e delete 0 end
  330.     .e insert end 0123456789
  331.     .e select from 3
  332.     .e select to 6
  333.     .e delete 0 end
  334.     .e selection present
  335. } {0}
  336. test entry-3.49 {EntryWidgetCmd procedure, "selection adjust" widget command} {
  337.     list [catch {.e select adjust x} msg] $msg
  338. } {1 {bad entry index "x"}}
  339. test entry-3.50 {EntryWidgetCmd procedure, "selection adjust" widget command} {
  340.     list [catch {.e select adjust 2 3} msg] $msg
  341. } {1 {wrong # args: should be ".e selection adjust index"}}
  342. test entry-3.51 {EntryWidgetCmd procedure, "selection adjust" widget command} {
  343.     .e delete 0 end
  344.     .e insert end "0123456789"
  345.     .e select from 1
  346.     .e select to 5
  347.     update
  348.     .e select adjust 4
  349.     selection get
  350. } {123}
  351. test entry-3.52 {EntryWidgetCmd procedure, "selection adjust" widget command} {
  352.     .e delete 0 end
  353.     .e insert end "0123456789"
  354.     .e select from 1
  355.     .e select to 5
  356.     update
  357.     .e select adjust 2
  358.     selection get
  359. } {234}
  360. test entry-3.53 {EntryWidgetCmd procedure, "selection from" widget command} {
  361.     list [catch {.e select from 2 3} msg] $msg
  362. } {1 {wrong # args: should be ".e selection from index"}}
  363. test entry-3.54 {EntryWidgetCmd procedure, "selection range" widget command} {
  364.     list [catch {.e select range 2} msg] $msg
  365. } {1 {wrong # args: should be ".e selection range start end"}}
  366. test entry-3.55 {EntryWidgetCmd procedure, "selection range" widget command} {
  367.     list [catch {.e selection range 2 3 4} msg] $msg
  368. } {1 {wrong # args: should be ".e selection range start end"}}
  369. test entry-3.56 {EntryWidgetCmd procedure, "selection range" widget command} {
  370.     .e delete 0 end
  371.     .e insert end 0123456789
  372.     .e select from 1
  373.     .e select to 5
  374.     .e select range 4 4
  375.     list [catch {.e index sel.first} msg] $msg
  376. } {1 {selection isn't in entry}}
  377. test entry-3.57 {EntryWidgetCmd procedure, "selection range" widget command} {
  378.     .e delete 0 end
  379.     .e insert end 0123456789
  380.     .e select from 3
  381.     .e select to 7
  382.     .e select range 2 9
  383.     list [.e index sel.first] [.e index sel.last] [.e index anchor]
  384. } {2 9 3}
  385. .e delete 0 end
  386. .e insert end "This is quite a long text string, so long that it "
  387. .e insert end "runs off the end of the window quite a bit."
  388. test entry-3.58 {EntryWidgetCmd procedure, "selection to" widget command} {
  389.     list [catch {.e select to 2 3} msg] $msg
  390. } {1 {wrong # args: should be ".e selection to index"}}
  391. test entry-3.59 {EntryWidgetCmd procedure, "xview" widget command} {
  392.     .e xview 5
  393.     .e xview
  394. } {0.0537634 0.268817}
  395. test entry-3.60 {EntryWidgetCmd procedure, "xview" widget command} {
  396.     list [catch {.e xview gorp} msg] $msg
  397. } {1 {bad entry index "gorp"}}
  398. test entry-3.61 {EntryWidgetCmd procedure, "xview" widget command} {
  399.     .e xview 0
  400.     .e icursor 10
  401.     .e xview insert
  402.     .e xview
  403. } {0.107527 0.322581}
  404. test entry-3.62 {EntryWidgetCmd procedure, "xview" widget command} {
  405.     list [catch {.e xview moveto foo bar} msg] $msg
  406. } {1 {wrong # args: should be ".e xview moveto fraction"}}
  407. test entry-3.63 {EntryWidgetCmd procedure, "xview" widget command} {
  408.     list [catch {.e xview moveto foo} msg] $msg
  409. } {1 {expected floating-point number but got "foo"}}
  410. test entry-3.64 {EntryWidgetCmd procedure, "xview" widget command} {
  411.     .e xview moveto 0.5
  412.     .e xview
  413. } {0.505376 0.72043}
  414. test entry-3.65 {EntryWidgetCmd procedure, "xview" widget command} {
  415.     list [catch {.e xview scroll 24} msg] $msg
  416. } {1 {wrong # args: should be ".e xview scroll number units|pages"}}
  417. test entry-3.66 {EntryWidgetCmd procedure, "xview" widget command} {
  418.     list [catch {.e xview scroll gorp units} msg] $msg
  419. } {1 {expected integer but got "gorp"}}
  420. test entry-3.67 {EntryWidgetCmd procedure, "xview" widget command} {
  421.     .e xview moveto 0
  422.     .e xview scroll 1 pages
  423.     .e xview
  424. } {0.193548 0.408602}
  425. test entry-3.68 {EntryWidgetCmd procedure, "xview" widget command} {
  426.     .e xview moveto .9
  427.     update
  428.     .e xview scroll -2 p
  429.     .e xview
  430. } {0.397849 0.612903}
  431. test entry-3.69 {EntryWidgetCmd procedure, "xview" widget command} {
  432.     .e xview 30
  433.     update
  434.     .e xview scroll 2 units 
  435.     .e index @0
  436. } {32}
  437. test entry-3.70 {EntryWidgetCmd procedure, "xview" widget command} {
  438.     .e xview 30
  439.     update
  440.     .e xview scroll -1 units 
  441.     .e index @0
  442. } {29}
  443. test entry-3.71 {EntryWidgetCmd procedure, "xview" widget command} {
  444.     list [catch {.e xview scroll 23 foobars} msg] $msg
  445. } {1 {bad argument "foobars": must be units or pages}}
  446. test entry-3.72 {EntryWidgetCmd procedure, "xview" widget command} {
  447.     list [catch {.e xview eat 23 hamburgers} msg] $msg
  448. } {1 {unknown option "eat": must be moveto or scroll}}
  449. test entry-3.73 {EntryWidgetCmd procedure, "xview" widget command} {
  450.     .e xview 0
  451.     update
  452.     .e xview -4
  453.     .e index @0
  454. } {0}
  455. test entry-3.74 {EntryWidgetCmd procedure, "xview" widget command} {
  456.     .e xview 300
  457.     .e index @0
  458. } {73}
  459. test entry-3.75 {EntryWidgetCmd procedure} {
  460.     list [catch {.e gorp} msg] $msg
  461. } {1 {bad option "gorp": must be bbox, cget, configure, delete, get, icursor, index, insert, scan, selection, or xview}}
  462.  
  463. # The test below doesn't actually check anything directly, but if run
  464. # with Purify or some other memory-allocation-checking program it will
  465. # ensure that resources get properly freed.
  466.  
  467. test entry-4.1 {DestroyEntry procedure} {
  468.     catch {destroy .e}
  469.     entry .e -textvariable x -show *
  470.     pack .e
  471.     .e insert end "Sample text"
  472.     update
  473.     destroy .e
  474. } {}
  475.  
  476. frame .f -width 200 -height 50 -relief raised -bd 2
  477. pack .f -side right
  478. test entry-5.1 {ConfigureEntry procedure, -textvariable} {
  479.     catch {destroy .e}
  480.     set x 12345
  481.     entry .e -textvariable x
  482.     .e get
  483. } {12345}
  484. test entry-5.2 {ConfigureEntry procedure, -textvariable} {
  485.     catch {destroy .e}
  486.     set x 12345
  487.     entry .e -textvariable x
  488.     set y abcde
  489.     .e configure -textvariable y
  490.     set x 54321
  491.     .e get
  492. } {abcde}
  493. test entry-5.3 {ConfigureEntry procedure, -textvariable} {
  494.     catch {destroy .e}
  495.     catch {unset x}
  496.     entry .e
  497.     .e insert 0 "Some text"
  498.     .e configure -textvariable x
  499.     set x
  500. } {Some text}
  501. test entry-5.4 {ConfigureEntry procedure, -textvariable} {
  502.     proc override args {
  503.     global x
  504.     set x 12345
  505.     }
  506.     catch {destroy .e}
  507.     catch {unset x}
  508.     trace variable x w override
  509.     entry .e
  510.     .e insert 0 "Some text"
  511.     .e configure -textvariable x
  512.     set result [list $x [.e get]]
  513.     unset x;  rename override {}
  514.     set result
  515. } {12345 12345}
  516. test entry-5.5 {ConfigureEntry procedure} {
  517.     catch {destroy .e}
  518.     entry .e -exportselection false
  519.     pack .e
  520.     .e insert end "0123456789"
  521.     .sel select from 0
  522.     .sel select to 10
  523.     set x {}
  524.     lappend x [selection get]
  525.     .e select from 1
  526.     .e select to 5
  527.     lappend x [selection get]
  528.     .e configure -exportselection 1
  529.     lappend x [selection get]
  530.     set x
  531. } {{This is so} {This is so} 1234}
  532. test entry-5.6 {ConfigureEntry procedure} {
  533.     catch {destroy .e}
  534.     entry .e
  535.     pack .e
  536.     .e insert end "0123456789"
  537.     .e select from 1
  538.     .e select to 5
  539.     .e configure -exportselection 0
  540.     list [catch {selection get} msg] $msg [.e index sel.first] \
  541.         [.e index sel.last]
  542. } {1 {PRIMARY selection doesn't exist or form "STRING" not defined} 1 5}
  543. test entry-5.7 {ConfigureEntry procedure} {
  544.     catch {destroy .e}
  545.     entry .e -font $fixed -width 4 -xscrollcommand scroll
  546.     pack .e
  547.     .e insert end "01234567890"
  548.     update
  549.     .e configure -width 5
  550.     set scrollInfo
  551. } {0 0.363636}
  552. test entry-5.8 {ConfigureEntry procedure} {fonts} {
  553.     catch {destroy .e}
  554.     entry .e -width 0
  555.     pack .e
  556.     .e insert end "0123"
  557.     update
  558.     .e configure -font $big
  559.     update
  560.     winfo geom .e
  561. } {62x37+0+0}
  562. test entry-5.9 {ConfigureEntry procedure} {fonts} {
  563.     catch {destroy .e}
  564.     entry .e -font $fixed -bd 2 -relief raised
  565.     pack .e
  566.     .e insert end "0123"
  567.     update
  568.     list [.e index @10] [.e index @11] [.e index @12] [.e index @13]
  569. } {0 0 1 1}
  570. test entry-5.10 {ConfigureEntry procedure} {fonts} {
  571.     catch {destroy .e}
  572.     entry .e -font $fixed -bd 2 -relief flat
  573.     pack .e
  574.     .e insert end "0123"
  575.     update
  576.     list [.e index @10] [.e index @11] [.e index @12] [.e index @13]
  577. } {0 0 1 1}
  578.  
  579. # No tests for DisplayEntry.
  580.  
  581. test entry-6.1 {EntryComputeGeometry procedure} {fonts} {
  582.     catch {destroy .e}
  583.     entry .e -font $fixed -bd 2 -relief raised -width 20 -highlightthickness 3
  584.     pack .e
  585.     .e insert end 012\t45
  586.     update
  587.     list [.e index @61] [.e index @62]
  588. } {3 4}
  589. test entry-6.2 {EntryComputeGeometry procedure} {fonts} {
  590.     catch {destroy .e}
  591.     entry .e -font $fixed -bd 2 -relief raised -width 20 -justify center \
  592.         -highlightthickness 3
  593.     pack .e
  594.     .e insert end 012\t45
  595.     update
  596.     list [.e index @96] [.e index @97]
  597. } {3 4}
  598. test entry-6.3 {EntryComputeGeometry procedure} {fonts} {
  599.     catch {destroy .e}
  600.     entry .e -font $fixed -bd 2 -relief raised -width 20 -justify right \
  601.         -highlightthickness 3
  602.     pack .e
  603.     .e insert end 012\t45
  604.     update
  605.     list [.e index @131] [.e index @132]
  606. } {3 4}
  607. test entry-6.4 {EntryComputeGeometry procedure} {
  608.     catch {destroy .e}
  609.     entry .e -font $fixed -bd 2 -relief raised -width 5
  610.     pack .e
  611.     .e insert end "01234567890"
  612.     update
  613.     .e xview 6
  614.     .e index @0
  615. } {6}
  616. test entry-6.5 {EntryComputeGeometry procedure} {
  617.     catch {destroy .e}
  618.     entry .e -font $fixed -bd 2 -relief raised -width 5
  619.     pack .e
  620.     .e insert end "01234567890"
  621.     update
  622.     .e xview 7
  623.     .e index @0
  624. } {6}
  625. test entry-6.6 {EntryComputeGeometry procedure} {fonts} {
  626.     catch {destroy .e}
  627.     entry .e -font $fixed -bd 2 -relief raised -width 10
  628.     pack .e
  629.     .e insert end "01234\t67890"
  630.     update
  631.     .e xview 3
  632.     list [.e index @39] [.e index @40]
  633. } {5 6}
  634. test entry-6.7 {EntryComputeGeometry procedure} {fonts} {
  635.     catch {destroy .e}
  636.     entry .e -font $big -bd 3 -relief raised -width 5
  637.     pack .e
  638.     .e insert end "01234567"
  639.     update
  640.     list [winfo reqwidth .e] [winfo reqheight .e]
  641. } {77 39}
  642. test entry-6.8 {EntryComputeGeometry procedure} {fonts} {
  643.     catch {destroy .e}
  644.     entry .e -font $big -bd 3 -relief raised -width 0
  645.     pack .e
  646.     .e insert end "01234567"
  647.     update
  648.     list [winfo reqwidth .e] [winfo reqheight .e]
  649. } {116 39}
  650. test entry-6.9 {EntryComputeGeometry procedure} {fonts} {
  651.     catch {destroy .e}
  652.     entry .e -font $big -bd 3 -relief raised -width 0 -highlightthickness 2
  653.     pack .e
  654.     update
  655.     list [winfo reqwidth .e] [winfo reqheight .e]
  656. } {25 39}
  657. test entry-6.10 {EntryComputeGeometry procedure} {fonts} {
  658.     catch {destroy .e}
  659.     entry .e -bd 1 -relief raised -width 0 -show .
  660.     .e insert 0 12345
  661.     pack .e
  662.     update
  663.     set x [winfo reqwidth .e]
  664.     .e configure -show X
  665.     lappend x [winfo reqwidth .e]
  666.     .e configure -show ""
  667.     lappend x [winfo reqwidth .e]
  668. } {23 53 43}
  669.  
  670. catch {destroy .e}
  671. entry .e -width 10 -font $fixed -textvariable contents -xscrollcommand scroll
  672. pack .e
  673. focus .e
  674. test entry-7.1 {InsertChars procedure} {
  675.     .e delete 0 end
  676.     .e insert 0 abcde
  677.     .e insert 2 XXX
  678.     update
  679.     list [.e get] $contents $scrollInfo
  680. } {abXXXcde abXXXcde {0 1}}
  681. test entry-7.2 {InsertChars procedure} {
  682.     .e delete 0 end
  683.     .e insert 0 abcde
  684.     .e insert 500 XXX
  685.     update
  686.     list [.e get] $contents $scrollInfo
  687. } {abcdeXXX abcdeXXX {0 1}}
  688. test entry-7.3 {InsertChars procedure} {
  689.     .e delete 0 end
  690.     .e insert 0 0123456789
  691.     .e select from 2
  692.     .e select to 6
  693.     .e insert 2 XXX
  694.     set x "[.e index sel.first] [.e index sel.last]"
  695.     .e select to 8
  696.     lappend x [.e index sel.first] [.e index sel.last]
  697. } {5 9 5 8}
  698. test entry-7.4 {InsertChars procedure} {
  699.     .e delete 0 end
  700.     .e insert 0 0123456789
  701.     .e select from 2
  702.     .e select to 6
  703.     .e insert 3 XXX
  704.     set x "[.e index sel.first] [.e index sel.last]"
  705.     .e select to 8
  706.     lappend x [.e index sel.first] [.e index sel.last]
  707. } {2 9 2 8}
  708. test entry-7.5 {InsertChars procedure} {
  709.     .e delete 0 end
  710.     .e insert 0 0123456789
  711.     .e select from 2
  712.     .e select to 6
  713.     .e insert 5 XXX
  714.     set x "[.e index sel.first] [.e index sel.last]"
  715.     .e select to 8
  716.     lappend x [.e index sel.first] [.e index sel.last]
  717. } {2 9 2 8}
  718. test entry-7.6 {InsertChars procedure} {
  719.     .e delete 0 end
  720.     .e insert 0 0123456789
  721.     .e select from 2
  722.     .e select to 6
  723.     .e insert 6 XXX
  724.     set x "[.e index sel.first] [.e index sel.last]"
  725.     .e select to 5
  726.     lappend x [.e index sel.first] [.e index sel.last]
  727. } {2 6 2 5}
  728. test entry-7.7 {InsertChars procedure} {
  729.     .e delete 0 end
  730.     .e insert 0 0123456789
  731.     .e icursor 4
  732.     .e insert 4 XXX
  733.     .e index insert
  734. } {7}
  735. test entry-7.8 {InsertChars procedure} {
  736.     .e delete 0 end
  737.     .e insert 0 0123456789
  738.     .e icursor 4
  739.     .e insert 5 XXX
  740.     .e index insert
  741. } {4}
  742. test entry-7.9 {InsertChars procedure} {
  743.     .e delete 0 end
  744.     .e insert 0 "This is a very long string"
  745.     update
  746.     .e xview 4
  747.     .e insert 3 XXX
  748.     .e index @0
  749. } {7}
  750. test entry-7.10 {InsertChars procedure} {
  751.     .e delete 0 end
  752.     .e insert 0 "This is a very long string"
  753.     update
  754.     .e xview 4
  755.     .e insert 4 XXX
  756.     .e index @0
  757. } {4}
  758. .e configure -width 0
  759. test entry-7.11 {InsertChars procedure} {fonts} {
  760.     .e delete 0 end
  761.     .e insert 0 "xyzzy"
  762.     update
  763.     .e insert 2 00
  764.     winfo reqwidth .e
  765. } {59}
  766.  
  767. .e configure -width 10
  768. test entry-8.1 {DeleteChars procedure} {
  769.     .e delete 0 end
  770.     .e insert 0 abcde
  771.     .e delete 2 4
  772.     update
  773.     list [.e get] $contents $scrollInfo
  774. } {abe abe {0 1}}
  775. test entry-8.2 {DeleteChars procedure} {
  776.     .e delete 0 end
  777.     .e insert 0 abcde
  778.     .e delete -2 2
  779.     update
  780.     list [.e get] $contents $scrollInfo
  781. } {cde cde {0 1}}
  782. test entry-8.3 {DeleteChars procedure} {
  783.     .e delete 0 end
  784.     .e insert 0 abcde
  785.     .e delete 3 1000
  786.     update
  787.     list [.e get] $contents $scrollInfo
  788. } {abc abc {0 1}}
  789. test entry-8.4 {DeleteChars procedure} {
  790.     .e delete 0 end
  791.     .e insert 0 0123456789abcde
  792.     .e select from 3
  793.     .e select to 8
  794.     .e delete 1 3
  795.     update
  796.     set x "[.e index sel.first] [.e index sel.last]"
  797.     .e select to 5
  798.     lappend x [.e index sel.first] [.e index sel.last]
  799. } {1 6 1 5}
  800. test entry-8.5 {DeleteChars procedure} {
  801.     .e delete 0 end
  802.     .e insert 0 0123456789abcde
  803.     .e select from 3
  804.     .e select to 8
  805.     .e delete 1 4
  806.     update
  807.     set x "[.e index sel.first] [.e index sel.last]"
  808.     .e select to 4
  809.     lappend x [.e index sel.first] [.e index sel.last]
  810. } {1 5 1 4}
  811. test entry-8.6 {DeleteChars procedure} {
  812.     .e delete 0 end
  813.     .e insert 0 0123456789abcde
  814.     .e select from 3
  815.     .e select to 8
  816.     .e delete 1 7
  817.     update
  818.     set x "[.e index sel.first] [.e index sel.last]"
  819.     .e select to 5
  820.     lappend x [.e index sel.first] [.e index sel.last]
  821. } {1 2 1 5}
  822. test entry-8.7 {DeleteChars procedure} {
  823.     .e delete 0 end
  824.     .e insert 0 0123456789abcde
  825.     .e select from 3
  826.     .e select to 8
  827.     .e delete 1 8
  828.     list [catch {.e index sel.first} msg] $msg
  829. } {1 {selection isn't in entry}}
  830. test entry-8.8 {DeleteChars procedure} {
  831.     .e delete 0 end
  832.     .e insert 0 0123456789abcde
  833.     .e select from 3
  834.     .e select to 8
  835.     .e delete 3 7
  836.     update
  837.     set x "[.e index sel.first] [.e index sel.last]"
  838.     .e select to 8
  839.     lappend x [.e index sel.first] [.e index sel.last]
  840. } {3 4 3 8}
  841. test entry-8.9 {DeleteChars procedure} {
  842.     .e delete 0 end
  843.     .e insert 0 0123456789abcde
  844.     .e select from 3
  845.     .e select to 8
  846.     .e delete 3 8
  847.     list [catch {.e index sel.first} msg] $msg
  848. } {1 {selection isn't in entry}}
  849. test entry-8.10 {DeleteChars procedure} {
  850.     .e delete 0 end
  851.     .e insert 0 0123456789abcde
  852.     .e select from 8
  853.     .e select to 3
  854.     .e delete 5 8
  855.     update
  856.     set x "[.e index sel.first] [.e index sel.last]"
  857.     .e select to 8
  858.     lappend x [.e index sel.first] [.e index sel.last]
  859. } {3 5 5 8}
  860. test entry-8.11 {DeleteChars procedure} {
  861.     .e delete 0 end
  862.     .e insert 0 0123456789abcde
  863.     .e select from 8
  864.     .e select to 3
  865.     .e delete 8 10
  866.     update
  867.     set x "[.e index sel.first] [.e index sel.last]"
  868.     .e select to 4
  869.     lappend x [.e index sel.first] [.e index sel.last]
  870. } {3 8 4 8}
  871. test entry-8.12 {DeleteChars procedure} {
  872.     .e delete 0 end
  873.     .e insert 0 0123456789abcde
  874.     .e icursor 4
  875.     .e delete 1 4
  876.     .e index insert
  877. } {1}
  878. test entry-8.13 {DeleteChars procedure} {
  879.     .e delete 0 end
  880.     .e insert 0 0123456789abcde
  881.     .e icursor 4
  882.     .e delete 1 5
  883.     .e index insert
  884. } {1}
  885. test entry-8.14 {DeleteChars procedure} {
  886.     .e delete 0 end
  887.     .e insert 0 0123456789abcde
  888.     .e icursor 4
  889.     .e delete 4 6
  890.     .e index insert
  891. } {4}
  892. test entry-8.15 {DeleteChars procedure} {
  893.     .e delete 0 end
  894.     .e insert 0 "This is a very long string"
  895.     .e xview 4
  896.     .e delete 1 4
  897.     .e index @0
  898. } {1}
  899. test entry-8.16 {DeleteChars procedure} {
  900.     .e delete 0 end
  901.     .e insert 0 "This is a very long string"
  902.     .e xview 4
  903.     .e delete 1 5
  904.     .e index @0
  905. } {1}
  906. test entry-8.17 {DeleteChars procedure} {
  907.     .e delete 0 end
  908.     .e insert 0 "This is a very long string"
  909.     .e xview 4
  910.     .e delete 4 6
  911.     .e index @0
  912. } {4}
  913. .e configure -width 0
  914. test entry-8.18 {DeleteChars procedure} {fonts} {
  915.     .e delete 0 end
  916.     .e insert 0 "xyzzy"
  917.     update
  918.     .e delete 2 4
  919.     winfo reqwidth .e
  920. } {31}
  921.  
  922. test entry-9.1 {EntryValueChanged procedure} {
  923.     catch {destroy .e}
  924.     proc override args {
  925.     global x
  926.     set x 12345
  927.     }
  928.     catch {unset x}
  929.     trace variable x w override
  930.     entry .e -textvariable x
  931.     .e insert 0 foo
  932.     set result [list $x [.e get]]
  933.     unset x; rename override {}
  934.     set result
  935. } {12345 12345}
  936.  
  937. catch {destroy .e}
  938. entry .e
  939. pack .e
  940. .e configure -width 0
  941. test entry-10.1 {EntrySetValue procedure} {fonts} {
  942.     set x abcde
  943.     set y ab
  944.     .e configure -textvariable x
  945.     update
  946.     .e configure -textvariable y
  947.     update
  948.     list [.e get] [winfo reqwidth .e]
  949. } {ab 24}
  950. test entry-10.2 {EntrySetValue procedure, updating selection} {
  951.     catch {destroy .e}
  952.     entry .e -textvariable x
  953.     .e insert 0 "abcdefghjklmnopqrstu"
  954.     .e selection range 4 10
  955.     set x "a"
  956.     list [catch {.e index sel.first} msg] $msg
  957. } {1 {selection isn't in entry}}
  958. test entry-10.3 {EntrySetValue procedure, updating selection} {
  959.     catch {destroy .e}
  960.     entry .e -textvariable x
  961.     .e insert 0 "abcdefghjklmnopqrstu"
  962.     .e selection range 4 10
  963.     set x "abcdefg"
  964.     list [.e index sel.first] [.e index sel.last]
  965. } {4 7}
  966. test entry-10.4 {EntrySetValue procedure, updating selection} {
  967.     catch {destroy .e}
  968.     entry .e -textvariable x
  969.     .e insert 0 "abcdefghjklmnopqrstu"
  970.     .e selection range 4 10
  971.     set x "abcdefghijklmn"
  972.     list [.e index sel.first] [.e index sel.last]
  973. } {4 10}
  974. test entry-10.5 {EntrySetValue procedure, updating display position} {
  975.     catch {destroy .e}
  976.     entry .e -width 10 -font $fixed -textvariable x
  977.     pack .e
  978.     .e insert 0 "abcdefghjklmnopqrstuvwxyz"
  979.     .e xview 10
  980.     update
  981.     set x "abcdefg"
  982.     update
  983.     .e index @0
  984. } {0}
  985. test entry-10.6 {EntrySetValue procedure, updating display position} {
  986.     catch {destroy .e}
  987.     entry .e -width 10 -font $fixed -textvariable x
  988.     pack .e
  989.     .e insert 0 "abcdefghjklmnopqrstuvwxyz"
  990.     .e xview 10
  991.     update
  992.     set x "1234567890123456789012"
  993.     update
  994.     .e index @0
  995. } {10}
  996. test entry-10.7 {EntrySetValue procedure, updating insertion cursor} {
  997.     catch {destroy .e}
  998.     entry .e -width 10 -font $fixed -textvariable x
  999.     pack .e
  1000.     .e insert 0 "abcdefghjklmnopqrstuvwxyz"
  1001.     .e icursor 5
  1002.     set x "123"
  1003.     .e index insert
  1004. } {3}
  1005. test entry-10.8 {EntrySetValue procedure, updating insertion cursor} {
  1006.     catch {destroy .e}
  1007.     entry .e -width 10 -font $fixed -textvariable x
  1008.     pack .e
  1009.     .e insert 0 "abcdefghjklmnopqrstuvwxyz"
  1010.     .e icursor 5
  1011.     set x "123456"
  1012.     .e index insert
  1013. } {5}
  1014.  
  1015. test entry-11.1 {EntryEventProc procedure} {
  1016.     catch {destroy .e}
  1017.     entry .e
  1018.     .e insert 0 abcdefg
  1019.     destroy .e
  1020.     update
  1021. } {}
  1022. test entry-11.2 {EntryEventProc procedure} {
  1023.     eval destroy [winfo children .]
  1024.     entry .e1 -fg #112233
  1025.     rename .e1 .e2
  1026.     set x {}
  1027.     lappend x [winfo children .]
  1028.     lappend x [.e2 cget -fg]
  1029.     destroy .e1
  1030.     lappend x [info command .e*] [winfo children .]
  1031. } {.e1 #112233 {} {}}
  1032.  
  1033. test entry-12.1 {EntryCmdDeletedProc procedure} {
  1034.     eval destroy [winfo children .]
  1035.     button .e1 -text "xyz_123"
  1036.     rename .e1 {}
  1037.     list [info command .e*] [winfo children .]
  1038. } {{} {}}
  1039.  
  1040. catch {destroy .e}
  1041. entry .e -font $fixed -width 5 -bd 2 -relief sunken
  1042. pack .e
  1043. .e insert 0 012345678901234567890
  1044. .e xview 4
  1045. update
  1046. test entry-13.1 {GetEntryIndex procedure} {
  1047.     .e index end
  1048. } {21}
  1049. test entry-13.2 {GetEntryIndex procedure} {
  1050.     list [catch {.e index abogus} msg] $msg
  1051. } {1 {bad entry index "abogus"}}
  1052. test entry-13.3 {GetEntryIndex procedure} {
  1053.     .e select from 1
  1054.     .e select to 6
  1055.     .e index anchor
  1056. } {1}
  1057. test entry-13.4 {GetEntryIndex procedure} {
  1058.     .e select from 4
  1059.     .e select to 1
  1060.     .e index anchor
  1061. } {4}
  1062. test entry-13.5 {GetEntryIndex procedure} {
  1063.     .e select from 3
  1064.     .e select to 15
  1065.     .e select adjust 4
  1066.     .e index anchor
  1067. } {15}
  1068. test entry-13.6 {GetEntryIndex procedure} {
  1069.     list [catch {.e index ebogus} msg] $msg
  1070. } {1 {bad entry index "ebogus"}}
  1071. test entry-13.7 {GetEntryIndex procedure} {
  1072.     .e icursor 2
  1073.     .e index insert
  1074. } {2}
  1075. test entry-13.8 {GetEntryIndex procedure} {
  1076.     list [catch {.e index ibogus} msg] $msg
  1077. } {1 {bad entry index "ibogus"}}
  1078. test entry-13.9 {GetEntryIndex procedure} {
  1079.     .e select from 1
  1080.     .e select to 6
  1081.     list [.e index sel.first] [.e index sel.last]
  1082. } {1 6}
  1083. selection clear .e
  1084. test entry-13.10 {GetEntryIndex procedure} {pc} {
  1085.     .e index sel.first
  1086. } {1}
  1087. test entry-13.11 {GetEntryIndex procedure} {!pc} {
  1088.     list [catch {.e index sel.first} msg] $msg
  1089. } {1 {selection isn't in entry}}
  1090. test entry-13.12 {GetEntryIndex procedure} {pc} {
  1091.     list [catch {.e index sbogus} msg] $msg
  1092. } {1 {bad entry index "sbogus"}}
  1093. test entry-13.13 {GetEntryIndex procedure} {!pc} {
  1094.     list [catch {.e index sbogus} msg] $msg
  1095. } {1 {selection isn't in entry}}
  1096. test entry-13.14 {GetEntryIndex procedure} {
  1097.     list [catch {.e index @xyz} msg] $msg
  1098. } {1 {bad entry index "@xyz"}}
  1099. test entry-13.15 {GetEntryIndex procedure} {fonts} {
  1100.     .e index @4
  1101. } {4}
  1102. test entry-13.16 {GetEntryIndex procedure} {fonts} {
  1103.     .e index @11
  1104. } {4}
  1105. test entry-13.17 {GetEntryIndex procedure} {fonts} {
  1106.     .e index @12
  1107. } {5}
  1108. test entry-13.18 {GetEntryIndex procedure} {fonts} {
  1109.     .e index @[expr [winfo width .e] - 6]
  1110. } {8}
  1111. test entry-13.19 {GetEntryIndex procedure} {fonts} {
  1112.     .e index @[expr [winfo width .e] - 5]
  1113. } {9}
  1114. test entry-13.20 {GetEntryIndex procedure} {
  1115.     .e index @1000
  1116. } {9}
  1117. test entry-13.21 {GetEntryIndex procedure} {
  1118.     list [catch {.e index 1xyz} msg] $msg
  1119. } {1 {bad entry index "1xyz"}}
  1120. test entry-13.22 {GetEntryIndex procedure} {
  1121.     .e index -10
  1122. } {0}
  1123. test entry-13.23 {GetEntryIndex procedure} {
  1124.     .e index 12
  1125. } {12}
  1126. test entry-13.24 {GetEntryIndex procedure} {
  1127.     .e index 49
  1128. } {21}
  1129. test entry-13.25 {GetEntryIndex procedure} {fonts} {
  1130.     catch {destroy .e}
  1131.     entry .e -show .
  1132.     .e insert 0 XXXYZZY
  1133.     pack .e
  1134.     update
  1135.     list [.e index @7] [.e index @8]
  1136. } {0 1}
  1137.  
  1138. # XXX Still need to write tests for EntryScanTo and EntrySelectTo.
  1139.  
  1140. set x {}
  1141. for {set i 1} {$i <= 500} {incr i} {
  1142.     append x "This is line $i, out of 500\n"
  1143. }
  1144. test entry-14.1 {EntryFetchSelection procedure} {
  1145.     catch {destroy .e}
  1146.     entry .e
  1147.     .e insert end "This is a test string"
  1148.     .e select from 1
  1149.     .e select to 18
  1150.     selection get
  1151. } {his is a test str}
  1152. test entry-14.2 {EntryFetchSelection procedure} {
  1153.     catch {destroy .e}
  1154.     entry .e -show *
  1155.     .e insert end "This is a test string"
  1156.     .e select from 1
  1157.     .e select to 18
  1158.     selection get
  1159. } {*****************}
  1160. test entry-14.3 {EntryFetchSelection procedure} {
  1161.     catch {destroy .e}
  1162.     entry .e
  1163.     .e insert end $x
  1164.     .e select from 0
  1165.     .e select to end
  1166.     string compare [selection get] $x
  1167. } 0
  1168.  
  1169. # No tests for EntryLostSelection or EventuallyRedraw.
  1170.  
  1171. catch {destroy .e}
  1172. entry .e -width 10 -xscrollcommand scroll
  1173. pack .e
  1174. update
  1175.  
  1176. test entry-15.1 {EntryVisibleRange procedure} {fonts} {
  1177.     .e delete 0 end
  1178.     .e insert 0 .............................
  1179.     .e xview
  1180. } {0 0.827586}
  1181. test entry-15.2 {EntryVisibleRange procedure} {fonts} {
  1182.     .e configure -show X
  1183.     .e delete 0 end
  1184.     .e insert 0 .............................
  1185.     .e xview
  1186. } {0 0.275862}
  1187. .e configure -show ""
  1188. test entry-15.3 {EntryVisibleRange procedure} {
  1189.     .e delete 0 end
  1190.     .e xview
  1191. } {0 1}
  1192.  
  1193. catch {destroy .e}
  1194. entry .e -width 10 -xscrollcommand scroll -font $fixed
  1195. pack .e
  1196. update
  1197. test entry-16.1 {EntryUpdateScrollbar procedure} {
  1198.     .e delete 0 end
  1199.     .e insert 0 123
  1200.     update
  1201.     set scrollInfo
  1202. } {0 1}
  1203. test entry-16.2 {EntryUpdateScrollbar procedure} {
  1204.     .e delete 0 end
  1205.     .e insert 0 0123456789abcdef
  1206.     .e xview 3
  1207.     update
  1208.     set scrollInfo
  1209. } {0.1875 0.8125}
  1210. test entry-16.3 {EntryUpdateScrollbar procedure} {
  1211.     .e delete 0 end
  1212.     .e insert 0 abcdefghijklmnopqrs
  1213.     .e xview 6
  1214.     update
  1215.     set scrollInfo
  1216. } {0.315789 0.842105}
  1217. test entry-16.4 {EntryUpdateScrollbar procedure} {
  1218.     catch {destroy .e}
  1219.     proc bgerror msg {
  1220.     global x
  1221.     set x $msg
  1222.     }
  1223.     entry .e -width 5 -xscrollcommand bogus
  1224.     pack .e
  1225.     update
  1226.     rename bgerror {}
  1227.     list $x $errorInfo
  1228. } {{invalid command name "bogus"} {invalid command name "bogus"
  1229.     while executing
  1230. "bogus 0 1"
  1231.     (horizontal scrolling command executed by entry)}}
  1232.  
  1233. set l [interp hidden]
  1234. eval destroy [winfo children .]
  1235.  
  1236. test entry-17.1 {Entry widget vs hiding} {
  1237.     catch {destroy .e}
  1238.     entry .e
  1239.     interp hide {} .e
  1240.     destroy .e
  1241.     list [winfo children .] [interp hidden]
  1242. } [list {} $l]    
  1243.     
  1244. # XXX Still need to write tests for EntryBlinkProc, EntryFocusProc,
  1245. # and EntryTextVarProc.
  1246.  
  1247. option clear
  1248.